import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";

function pathResolve(dir: string) {
    return resolve(__dirname, ".", dir);
}

export default defineConfig({
    resolve: {
        alias: [
            {
                find: /^\/@\//,
                replacement: pathResolve("src") + "/",
            },
        ],
    },
    css: {
        preprocessorOptions: {
            scss: {
                // * 引入 SCSS 全局样式：此处不能使用路径别名，同时后面的分号也必须要添加
                additionalData: `@import "./src/assets/common";`,
            },
        },
    },
    plugins: [
        vue({
            script: {
                refSugar: true,
            },
        }),
    ],
});
